<?php


require_once "gnc_mng.php";
 
class Main extends Gnc_mng {
	
	function index()
	{		
		$area = $this->model->get_data_from_query(array('nkey', 'nkey' => 'prefix', 'description'), NULL, NULL, array('position' => 'ASC'), NULL, NULL, 'sys_r_area');
		
		$application = $this->model->get_data_from_query(array('nkey' => 'prefix', 'key_sys_area', 'description', 'uri'), '`id` != \'0\'', NULL, NULL, NULL, NULL, 'sys_m_application');
		
		$applications_by_area = $area;
		
		foreach ($application as $apl_key => $apl_value) {
			foreach ($area as $area_key => $area_value) {
				if (strcasecmp($apl_value['key_sys_area'], $area_value['nkey'])==0) {
					$value = $apl_value;
					unset($value['key_sys_area']);
					$applications_by_area[$area_key]['applications'][] = $value;
				}
			}
		}
		
		$content_data = array(
			'applications_by_area' => $applications_by_area,
		);
		
		$data = array(
			'application' => '',
			'page' => 'Index',
			'navigation' => $this->load->view('form/login_sidebar', '', true),
			'content' => $this->load->view('viewer/main', $content_data, true),
		);	// data yang akan dipassing ke view
		$this->load->view('layout/default', $data);
	}
}
